{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Robodyno GPS Sensor API"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.初始化GPS对象"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`GpsSensor(can, id_)`\n",
    "\n",
    "参数：\n",
    "- `can` : can总线接口\n",
    "- `id_` : GPS驱动板模块ID，默认`0x32`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from robodyno.components import GpsSensor\n",
    "from robodyno.interfaces import CanBus\n",
    "can = CanBus()\n",
    "gps = GpsSensor(can, 0x32)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.读取GPS位置"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`get_position(timeout = None)`\n",
    "\n",
    "参数：\n",
    "\n",
    "- timeout : 请求超时时间(s)，默认为`None`\n",
    "\n",
    "返回值 ：\n",
    "\n",
    "- dict\n",
    "    - `Timestamp` : 时间戳\n",
    "    - `longitude` : 经度\n",
    "    - `latitude` : 纬度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gps.get_position()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.读取GPS位置(字符串格式)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`get_position(timeout = None)`\n",
    "\n",
    "参数：\n",
    "\n",
    "- timeout : 请求超时时间(s)，默认为`None`\n",
    "\n",
    "返回值 ：\n",
    "\n",
    "- str\n",
    "    - `Timestamp` : 时间戳\n",
    "    - `longitude` : 经度\n",
    "    - `latitude` : 纬度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gps.get_position_str()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4.设置CAN_ID"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`config_can_bus(new_id, bitrate = 1000000)`\n",
    "\n",
    "参数 ：\n",
    "\n",
    "- `new_id` ：GPS 传感器新CAN_ID (默认：`0x32`)\n",
    "- `bitrate` : CAN总线通讯速率\n",
    "    - 1000000\n",
    "    - 500000\n",
    "    - 250000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gps.config_can_bus(new_id=0x32, bitrate=1000000)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
